<template>
<div>
<input type='text' v-model='messageA'>
<HelloTest :inputMsg='messageA' v-on:passChildValue="passChildValue"> </HelloTest>
<span> 1111 {{spanValue}} 2222 </span>
<div>
<span> {{name}} </span>
<input type="button" value="点击触发" @click="getData">
</div>
</div>
</template>

<script>
import HelloTest from '@/components/HelloTest'
import Bus from '@/components/Bus.js'
export default {
  components: { HelloTest },
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      spanValue: '',
      messageA: '',
      name: 0
    }
  },
  mounted: function () {
    var vm = this
    Bus.$on('val', (data) => {
      console.log(data)
      vm.name = data
    })
  },
  methods: {
    passChildValue (passValue) {
      console.log('get a message' + passValue)
      this.spanValue += passValue
    },
    getData: function () {
      this.name++
    }
  }
}
</script>
